home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
Borland Visual dBASE Professiona v7.0
/
DATA1.CAB
/
Sample_dBASE
/
Mugs
/
Finder.wfm
< prev
next >
Wrap
Text File
|
1997-11-20
|
9KB
|
339 lines
//--------------------------------------------------------------
//
// Finder.wfm - Mugs Sample Application
//
// This is a general purpose locate dialog that
// searches a given rowset for a value contained
// in a single field.
//
// Dependencies: Requires an active rowset to
// perform searches.
//
// Visual dBASE Samples Group
//
// $Revision: 1.6 $
//
// Copyright (c) 1997, Borland International, Inc.
// All rights reserved.
//
//---------------------------------------------------------------
SET TALK OFF
** END HEADER -- do not remove this line
//
// Generated on 10/23/97
//
parameter bModal
local f
f = new FinderFORM()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class FinderFORM of FORM
with (this)
open = class::FORM_READMODAL
readModal = class::FORM_READMODAL
autoCenter = true
scaleFontSize = 8
scaleFontBold = false
height = 15.4091
left = 20.1429
top = 1.8182
width = 47.2857
text = "Locate Row"
mdi = false
icon = "resource #8220"
endwith
this.LABELWHAT = new TEXT(this)
with (this.LABELWHAT)
height = 1
left = 1
top = 1
width = 12
metric = 0
colorNormal = "BtnText"
fontName = "MS Sans Serif"
fontSize = 8
text = "Find What:"
endwith
this.ENTRYFIND = new ENTRYFIELD(this)
with (this.ENTRYFIND)
height = 1
left = 1
top = 2
width = 27
metric = 0
colorHighLight = ""
fontName = "MS Sans Serif"
fontSize = 8
value = ""
borderStyle = 7
endwith
this.SPINFIND = new SPINBOX(this)
with (this.SPINFIND)
visible = false
height = 1
left = 1
top = 2
width = 27
metric = 0
picture = "999999999999999999999"
colorHighLight = ""
rangeMax = 100
rangeMin = 1
fontName = "MS Sans Serif"
fontSize = 8
value = 1
validRequired = true
borderStyle = 7
endwith
this.LABELFIELD = new TEXT(this)
with (this.LABELFIELD)
height = 1
left = 1
top = 3.5
width = 16
metric = 0
colorNormal = "BtnText"
alignVertical = 1
fontName = "MS Sans Serif"
fontSize = 8
text = "Within Field:"
endwith
this.LISTFIELDS = new LISTBOX(this)
with (this.LISTFIELDS)
onSelChange = class::LISTFIELDS_ONSELCHANGE
onOpen = {;this.curSel := 1}
height = 6
left = 1
top = 4.5
width = 27
metric = 0
id = 101
fontName = "MS Sans Serif"
fontSize = 8
colorHighLight = "HighLightText/HighLight"
endwith
this.RECTANGLE1 = new RECTANGLE(this)
with (this.RECTANGLE1)
left = 1
top = 11
width = 45
height = 3.5
metric = 0
text = "Search Rules"
colorNormal = "WindowText/BtnFace"
fontName = "MS Sans Serif"
fontSize = 8
endwith
this.CHECKCASE = new CHECKBOX(this)
with (this.CHECKCASE)
transparent = false
height = 1
left = 27
top = 12
width = 18
text = "Match &Case"
metric = 0
colorNormal = "WindowText/BtnFace"
fontName = "MS Sans Serif"
fontSize = 8
value = false
group = true
endwith
this.CHECKSHOW = new CHECKBOX(this)
with (this.CHECKSHOW)
transparent = false
height = 1
left = 27
top = 13
width = 18
text = "Show E&xpression"
metric = 0
colorNormal = "WindowText/BtnFace"
fontName = "MS Sans Serif"
fontSize = 8
value = false
group = true
endwith
this.BUTTONFIND = new PUSHBUTTON(this)
with (this.BUTTONFIND)
onClick = class::BUTTONFIND_ONCLICK
height = 1.1818
left = 32
top = 1.5
width = 12
text = "&Find"
metric = 0
fontName = "MS Sans Serif"
fontSize = 8
group = true
colorNormal = "BtnText/BtnFace"
value = false
endwith
this.BUTTONCLOSE = new PUSHBUTTON(this)
with (this.BUTTONCLOSE)
onClick = {; this.form.close()}
height = 1.1818
left = 32
top = 3.5
width = 12
text = "Close"
metric = 0
fontName = "MS Sans Serif"
fontSize = 8
group = true
colorNormal = "BtnText/BtnFace"
value = false
endwith
this.COMBOMATCH = new COMBOBOX(this)
with (this.COMBOMATCH)
onOpen = {; this.value := "Start of Field"}
height = 1.1
left = 10
top = 12.5
width = 15
metric = 0
fontName = "MS Sans Serif"
fontSize = 8
dataSource = 'array {"Whole Field","Start of Field"}'
style = 2
endwith
this.LABELMATCH = new TEXT(this)
with (this.LABELMATCH)
height = 1
left = 2
top = 12.5
width = 6
metric = 0
colorNormal = "BtnText"
alignVertical = 1
fontName = "MS Sans Serif"
fontSize = 8
text = "Match:"
endwith
// {Linked Method} form.readModal
function Form_ReadModal
local bRead, rowFields
bRead = false
if ( NOT TYPE("this.rowset") == "O" )
MSGBOX("No rowset to search")
else
rowFields = this.rowset.fields
this.listFields.options = new Array()
for i = 1 to rowFields.size
if ( rowFields[i].type == "CHARACTER" OR ;
rowFields[i].type == "AUTOINC" OR ;
rowFields[i].type == "NUMERIC" OR ;
rowFields[i].type == "LONG" )
if ( rowFields[i].lookupSQL == "" )
this.listFields.options.add( rowFields[i].fieldName )
endif
endif
next
this.listFields.options.sort()
with ( this.ListFields )
dataSource := "ARRAY FORM.LISTFIELDS.options"
curSel := 1
endwith
bRead := FINDERFORM::ReadModal()
endif
return ( bRead )
// {Linked Method} form.buttonfind.onClick
function BUTTONFIND_OnClick
local thisRow, thisField, mBookmark, sSearchExp
local bString, bFound
thisRow = this.form.rowset
thisField = thisRow.fields[this.form.LISTFIELDS.value]
bString = ( thisField.type == "CHARACTER" )
bFound = false
mBookmark = thisRow.bookmark()
sSearchExp = ""
if ( bString )
do case
case ( this.form.CheckCase.value AND ;
this.form.ComboMatch.value == "Whole Field" )
thisRow.locateOptions := 0 // exact and case
case ( this.form.CheckCase.value )
thisRow.locateOptions := 1 // non-exact - match case
case ( this.form.ComboMatch.value == "Whole Field" )
thisRow.locateOptions := 2 // exact - ignore case
otherwise
thisRow.locateOptions := 3 // non-exact - ignore case
endcase
sSearchExp := '"' + this.form.listFields.value + '" = ' + ;
"'" + LTRIM(RTRIM(this.form.entryFind.value)) + "'"
else
sSearchExp := '"' + this.form.listFields.value + '" = ' + ;
LTRIM(STR(this.form.spinFind.value))
endif
if ( this.form.checkshow.value )
MSGBOX( sSearchExp,'SQL search expression')
this.form.setFocus()
endif
try
bFound := thisRow.applyLocate( sSearchExp )
if ( NOT bFound )
MSGBOX('Value was not found.','Alert', 48)
thisRow.goto( mBookmark )
endif
catch ( Exception e )
bFound := false
thisRow.goto( mBookmark )
MSGBOX('Could not perform locate.','Alert', 48)
endtry
if ( bFound )
this.form.close()
endif
return ( bFound )
// {Linked Method} form.listfields.onSelChange
function LISTFIELDS_OnSelChange
local bString, rowFields
rowFields = this.form.rowset.fields
bString = ( rowFields[this.value].type == "CHARACTER" or ;
rowFields[this.value].type == "MEMO" )
with ( this.form )
entryFind.visible := bString
comboMatch.enabled := bString
checkCase.enabled := bString
spinFind.visible := ( NOT bString )
endwith
return ( bString )
endclass